home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Original Shareware 1.1
/
The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso
/
18
/
fpc103.zip
/
FWORDS.SEQ
< prev
next >
Wrap
Text File
|
1988-06-30
|
7KB
|
181 lines
\ FLOOK.SEQ File searching by Tom Zimmer
comment:
Some powerful file manipulation words are now being loaded, these
words allow printing, searching and listing the first line of
sequential files. Here is a synopsis:
FLOOK <string> <filespec#1> <filespec#2> ... to end of line
INDEX <filespec#1> <filespec#2> ... " "
FPRINT <filespec#1> <filespec#2> ... " "
Each of the words may be followed by as many filespecs as will fit on
a line. The filespecs will be precessed left to right. Filespecs can
be "*.*", or "*.SEQ", or "ANYFILE", or any other filespec you want. It
is probably not a good idea to use these words on .EXE or .COM files
though.
Here is an example of how FLOOK might be used:
FLOOK <string> F-PC COLOR STATUS <enter>
will search the files F-PC.SEQ, COLOR.SEQ, and STATUS.SEQ for <string>
comment;
only forth also editor also hidden definitions also
defer donfile \ A function to do on all specified files
' noop is donfile
variable fstime
: .file-once ( --- )
fstime @ 0=
if cr .shndl fstime on
then ;
variable noise
code searchsetup ( --- a1 n1 a2 n2 )
mov bx, # slook.buf 1+ \ slook.buf count
push bx
mov al, slook.buf byte
sub ah, ah
push ax
mov bx, # outbuf 1+ \ outbuf count
push bx
mov al, outbuf byte
1push
end-code
: searchfile ( --- )
IBRESET
0.0 seek
fstime off noise @ if ." ." ?cr then
8000 1
do lineread c@ 0= ?leave
searchsetup search nip
if noise @
if .file-once
cr i 3 .r space
else cr
then outbuf count 2- type
?keypause
PRINTING @ 0= statv @ and
IF <.STAT> THEN
then
loop fstime @ if cr then ;
: searchedit ( --- )
[ forth ]
IBRESET
0.0 seek
." ." ?cr
8000 1
do ?keypause
lineread c@ 0= ?leave
searchsetup search nip
if i loadline !
savescr #out @ #line @ 2>r
byte|line off
?readfile
shndl @ hclose drop
backingup @ renaming !
8 scrline !
reedit
shndl @ memfile $>handle
shndl @ hopen drop \ Reopen file
restscr 2r> at
leave
then
loop ;
variable withname
: .firstline ( --- )
IBRESET
0.0 seek
cr lineread count 2- 0 max withname @
if .shndl 20 #out @ - 0 max spaces
60
else 79
then min type
?keypause ;
only forth also definitions editor also hidden also
: fallof ( func | file_specs --- ) \ Do something to all files
\ matching file_specs.
is donfile \ Set function to be performed.
dirinit
dirseg 0= if span @ >in ! exit then
begin >in @ span @ <
while bl word \ else get the file spec
dup
$getdir \ and read the directory files.
#fls 0=
if cr count type ." No matching files."
else drop #fls 0
?do i >fadr 1+ c@l ascii . <>
if i >fadr dir>pad >r
here shndl+ $>handle
shndl+ >pathend
dup shndl+ 1+ - r@ + shndl+ c!
r> cmove
shndl+ count + off
shndl+ $hopen 0=
if PRINTING @ 0=
statv @ and
IF <.STAT>
THEN donfile
then close ?keypause
then
loop
then
repeat cr ;
: flook ( search_string file_specs --- ) \ Search files for string
SAVESTATE noise on
>in @ span @ 1- > \ if nothing following command
if cr ." String to LOOK for ->" query 0 word
else bl word
then slook.buf over c@ 1+ 32 min cmove
>in @ span @ 1- > \ if nothing following command
if cr ." File spec to search ->" query
then ['] searchfile fallof
RESTORESTATE ;
: editall ( search_string file_specs --- ) \ edit all files containing
SAVESTATE
>in @ span @ 1- > \ if nothing following command
if cr ." String to LOOK for and EDIT ->" query 0 word
else bl word
then slook.buf over c@ 1+ 32 min cmove
>in @ span @ 1- > \ if nothing following command
if cr ." File spec to search ->" query
then ['] searchedit fallof
RESTORESTATE ;
: index ( file_spec --- ) \ Print first line of files
SAVESTATE
cr cr ." **** Use SPACE to pause, and ESC to stop. ****"
cr 3 tenths withname on
>in @ span @ 1- > \ if nothing following command
if " *.seq" ">$ $>tib \ substitute "*.seq"
withname off
then ['] .firstline fallof
RESTORESTATE ;
: fprint ( file_specs --- ) \ Print files specified.
SAVESTATE
>in @ span @ 1- > \ if nothing following command
if cr ." File spec to print ->" query
then ['] listing fallof
RESTORESTATE ;
only forth also definitions